package com.globallogic.vacationplanner.model.entity;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "user", catalog = "vacation_planner", uniqueConstraints = @UniqueConstraint(columnNames = "login"))
public class User implements java.io.Serializable {
	private static final long serialVersionUID = 1L;
	private Integer idUser;
	private String login;
	private String password;
	private String username;
	private String surname;
	private String email;
	private Set<Project> ownProjects = new HashSet<Project>(0);
	private Set<Vacation> vacations = new HashSet<Vacation>(0);
	private Set<Project> memberedProjects = new HashSet<Project>();

	public User() {
	}

	public User(String login, String password, String username, String surname,
			String email) {
		this.login = login;
		this.password = password;
		this.username = username;
		this.surname = surname;
		this.email = email;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id_user", unique = true, nullable = false)
	public Integer getIdUser() {
		return this.idUser;
	}

	public void setIdUser(Integer idUser) {
		this.idUser = idUser;
	}

	@Column(name = "login", unique = true, nullable = false, length = 10)
	public String getLogin() {
		return this.login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	@Column(name = "password", nullable = false, length = 45)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "username", nullable = false, length = 45)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "surname", nullable = false, length = 45)
	public String getSurname() {
		return this.surname;
	}

	public void setSurname(String surname) {
		this.surname = surname;
	}

	@Column(name = "email", nullable = false, length = 45)
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
	public Set<Project> getOwnProjects() {
		return this.ownProjects;
	}

	public void setOwnProjects(Set<Project> projects) {
		this.ownProjects = projects;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
	public Set<Vacation> getVacations() {
		return this.vacations;
	}

	public void setVacations(Set<Vacation> vacations) {
		this.vacations = vacations;
	}

	@ManyToMany(fetch = FetchType.LAZY, mappedBy = "memberedUsers")
	public Set<Project> getMemberedProjects() {
		return memberedProjects;
	}

	public void setMemberedProjects(Set<Project> memberedProjects) {
		this.memberedProjects = memberedProjects;
	}

}
